<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div style="width: 100px;height: 100px;background: red" onclick="checkTime()">点击</div>
</body>
</html>
<script>
    function checkTime() {
        const date = new Date()
        let time_text = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} 08:00:00`
        let start_time = null

        if (date.getHours() <= 8) {
            start_time = new Date(time_text).getTime() - 1000 * 60 * 60 * 24
        } else {
            console.log(date)
            start_time = new Date(time_text).getTime()
        }
        console.log(start_time)
    }
</script>